package com.woniuxy.microsysserver.feignfullback;

import com.alibaba.fastjson.JSONObject;
import com.woniuxy.bean.ResultBean;
import com.woniuxy.microsysserver.feign.GoldFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * Auther: wuson  <br/>
 * Date: 2021/3/9:16:36  <br/>
 * Description:
 */
@Slf4j
@Component
public class GoldFullBackFactary implements FallbackFactory<GoldFeign> {
    @Override
    public GoldFeign create (Throwable throwable) {
        log.error("错误信息----{}", throwable);
        return name -> JSONObject.toJSONString(ResultBean.builder().code(1000).msg("黄金服务异常，开启降级！").build());
    }
}
